package by.bsuir.chess.validators
{
	import by.bsuir.chess.models.GameModel;
	import by.bsuir.chess.vo.Piece;

	import flash.geom.Point;

	public class PiecePositionValidator
	{
		//check if point is not outside the board and there's no piece of same color
		public static function validate(piece : Piece, p : Point) : Boolean
		{
			var insideBoard : Boolean = p.x <= 8 && p.x >= 1 && p.y <= 8 && p.y >= 1;
			var testPiece : Piece = GameModel.inst.boardState[p.x][p.y];
			//check if piece exists there
			var cellAllowed : Boolean = !testPiece || testPiece.color != piece.color;
			return insideBoard && cellAllowed;
		}
	}
}
